<template>
<!-- <form action="/api/users/login" method="post"> -->

    用户名：<input name="username" v-model="uname"> <br/>
    密码：<input name="pwd" v-model="pwd"> <br/>
    <button type="submit" @click="loginOn">登录</button>



   
<!-- </form> -->
</template>

<script setup>
import {ref,onMounted} from 'vue'
import { ElMessage } from 'element-plus'
import { login } from "../request/user"

import {TodoColumns,TodoUrlSet,netUtil,States} from "../models/columns"
const uname=ref('')

const pwd=ref('')
const loginOn=async ()=>{

   const result= await login({username:uname.value,pwd:pwd.value})
  
   console.log(result)
   if(result&&result.data){

   const r=result.data
      if(r.errno){

        ElMessage({
    message: '登录失败！',
    type: 'error',
  })
      }else{
        ElMessage({
    message: '登录成功！',
    type: 'success',
  })

  localStorage.setItem('token','123')


      }


   }
}
const savedialogRef = ref();
const dialogObj = ref()
// 打开保存弹窗
const onOpenSaveDialog = () => {
    const row = {}

    dialogTitle.value = '用户登录'

    dialogObj.value = row
    savedialogRef.value.openDialog(row);
};
let dialogTitle = ref('');
// const cannotSendCode = computed(() => {
//     return !dialogObj.value['userName'] || dialogObj.value['userName'].indexOf('@') == -1
// })
onMounted(async () => {
    // if (redirectUrl) {        
    //     regRoute.value += '?redirect=' + redirectUrl
    //     if (queryStr) {
    //         regRoute.value += '&params=' + queryStr          
    //     }
    // }

    onOpenSaveDialog()
})
</script>